;(function () {
    // importCss();
    var _global;
    var TV = function () {
    };
    TV.prototype = {
        prevFocus: '',//上一个焦点
        curFocus: '',//当前焦点
        nextTopFocus: '',
        nextBottomFocus: '',
        nextLeftFocus: '',
        nextRightFocus: '',
        focusStack: [],
        handlers: [],
        //移动到上一个焦点
        moveToPrevFocus: function () {

        },
        //移动到下一个焦点
        moveToNextFocus: function (direction) {
            this.emit({type:'focus'});
            switch(direction){
                case 'top':
                    this.moveToNextTopFocus();
                    break;
                case 'bottom':
                    this.moveToNextBottomFocus();
                    break;
                case 'left':
                    this.moveToNextLeftFocus();
                    break;
                case 'right':
                    this.moveToNextRightFocus();
                    break;
                default:
                    break;
            }
            this.emit({type:'blur'});
        },
        //移动到下一个上焦点
        moveToNextTopFocus: function () {

        },
        //移动到下一个下焦点
        moveToNextBottomFocus: function () {

        },
        //移动到下一个左焦点
        moveToNextLeftFocus: function () {

        },
        //移动到下一个右焦点
        moveToNextRightFocus: function () {

        },
        on: function () {

        },
        off: function () {

        },
        emit: function () {

        }
    };

    function importCss() {
        var head = document.getElementsByTagName("head");
        var css = document.createElement("link");
        css.href = '../css/plug-in/keyboard.css';
        css.rel = "stylesheet";
        css.type = "text/css";
        head[0].appendChild(css);
    }

    if (!('getElementsByClass' in HTMLElement)) {
        HTMLElement.prototype.getElementsByClassName = function (n, tar) {
            var el = [],
                _el = (!!tar ? tar : this).getElementsByTagName('*');
            for (var i = 0; i < _el.length; i++) {
                if (!!_el[i].className && (typeof _el[i].className == 'string') && _el[i].className.match(new RegExp('(\\s|^)' + n + '(\\s|$)'))) {
                    el[el.length] = _el[i];
                }
            }
            return el;
        };
        ((typeof HTMLDocument !== 'undefined') ? HTMLDocument : Document).prototype.getElementsByClassName = HTMLElement.prototype.getElementsByClassName;
    }

    function extend(target, options, deep) {
        for (var key in options) {
            if (options.hasOwnProperty(key)) {
                var copy = options[key];
                if (deep && copy instanceof Array) {
                    target[key] = extend(target[key], copy, deep);
                } else if (deep && copy instanceof Object) {
                    target[key] = extend(target[key], copy, deep);
                } else {
                    target[key] = options[key];
                }
            }
        }
        return target;
    }

    _global = (function () {
        return this || (0, eval)('this');
    }());
    if (typeof module !== "undefined" && module.exports) {
        module.exports = TV;
    } else if (typeof define === "function" && define.amd) {
        define(function () {
            return TV;
        });
    } else {
        !('TV' in _global) && (_global.TV = TV);
    }
})
();
